# -*- coding:utf-8 -*-
'''
@Author: lindes
'''
import xadmin
from .models import PostImages, Post, PraisePost, InformPost, CollectPost, CommentPost


class PostsAdmin:
    list_display = ['title', 'author', 'add_time', 'content', 'click_count', 'praise_count', 'comment_count', 'collect_count',
                    'inform_count']
    list_filter = ['title', 'click_count', 'praise_count', 'comment_count', 'collect_count', 'inform_count']
    search_fields = ['title']

    style_fields = {"content": "ueditor"}

    class PostImagesInline:
        model = PostImages
        exclude = ['add_time', 'delete_time', 'is_delete']

    list_editable = ['title', 'author', 'content']
    style_fields = {"content": "ueditor"}

    class PostImagesInline(object):
        model = PostImages
        exclude = ['add_time']
        extra = 1

        style = 'tab'

    inlines = [PostImagesInline]


class PraisePostAdmin:
    list_display = ['user', 'post', 'add_time']
    list_filter = ['add_time']
    search_fields = ['user']


class InformPostAdmin:
    list_display = ['user', 'post', 'add_time']
    list_filter = ['add_time']
    search_fields = ['user']


class CollectPostAdmin:
    list_display = ['user', 'post', 'add_time']
    list_filter = ['add_time']
    search_fields = ['user']


class CommentPostAdmin:
    list_display = ['user', 'post', 'pid', 'content', 'add_time']
    list_filter = ['post', 'add_time']
    search_fields = ['user', 'content']


xadmin.site.register(Post, PostsAdmin)
xadmin.site.register(PraisePost, PraisePostAdmin)
xadmin.site.register(InformPost, InformPostAdmin)
xadmin.site.register(CollectPost, CollectPostAdmin)
xadmin.site.register(CommentPost, CommentPostAdmin)
